package com.songsf.learn.rest;

import com.alibaba.fastjson.JSONObject;
import com.songsf.learn.Book;
import com.songsf.learn.service.AsynchService;
import com.songsf.learn.service.BookCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Future;

/**
 * Created by songsf on 2017/11/17.
 */
@RestController
@RequestMapping(value = "/api/v1.0")
public class AsynchTestController {
    @Autowired
    private BookCache bookCache;
    @Autowired
    private AsynchService asynchService;

    @RequestMapping(value = "/asynch/test",method = RequestMethod.GET)
    public JSONObject asynchTest(){
        JSONObject response = new JSONObject();
        Book book = bookCache.getBook("中飞");
        asynchService.otherOperate();
        response.put("data",book);
        return response;
    }
}
